// $Id: transfer.h 54 2004-10-11 15:31:22Z jonas $
#ifndef TRANSFER_H
#define TRANSFER_H

#include "clock.h"

class Node;
class StoredFile;

/**
 * Transfers are owned by Nodes. Nodes create and delete transfers, but the
 * Network transfers the data. All transfers are one way. They transfer from
 * the owner of the transfer object, to the node found in the "m_destination"
 * propertie. Make sure not to remove a stored file which is involved in a
 * transfer (on sender AND receiver side) unless you remove the transfer first.
 */
class Transfer {
public:
	Transfer(Node *destination, StoredFile *file) : m_guid(m_nextGuid++), m_destination(destination), m_file(file), m_isRootTransfer(false), m_timeLastUsed(4294967295U) {}

	/**
	 * A unique identifier of this transfer.
	 */
	const unsigned int m_guid;

	/**
	 * A pointer to the node we are transfering the file to.
	 */
	const Node *m_destination;

	/**
	 * A pointer to the file we are transfering.
	 */
	const StoredFile *m_file;

	/**
	 * True if this is the origin/root of a transfer chain.
	 */
	bool m_isRootTransfer;

	/**
	 * This transfer transfered something at this timestep (most recently).
	 */
	 unsigned int m_timeLastUsed;

private:
	/**
	 * @todo Write documentation
	 */
	static unsigned int m_nextGuid;
};

#endif
